﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Apps.Model.Attendance;

namespace EzDesk.Apps.ServiceImpl.Attendance.Repositories
{
    public partial class AttendanceInfoRepository
    {
        public List<AttendanceInfo> GetAttendanceInfoList(DateTime startDate, DateTime endDate, List<Guid> userIdList, AttendanceType? attendanceType)
        {
            var allInfos = GetAll();

            allInfos = allInfos.Where(p => p.Date >= startDate.Date && p.Date <= endDate.Date);
            if (attendanceType != null)
            {
                allInfos = allInfos.Where(p => p.AttendanceType == attendanceType.GetValueOrDefault());
            }

            if (userIdList != null)
            {
                allInfos = allInfos.Where(p => userIdList.Contains(p.UserId));
            }

            return allInfos.OrderBy(x => x.ActionTime).ToList();
        }
    }
}
